<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Qiniu\Processing;

class Operation
{
    private $auth;
    private $token_expire;
    private $domain;
    public function __construct($domain, $auth = NULL, $token_expire = 3600)
    {
        $this->auth = $auth;
        $this->domain = $domain;
        $this->token_expire = $token_expire;
    }
    public function execute($key, $fops)
    {
        $url = $this->buildUrl($key, $fops);
        $resp = \Qiniu\Http\Client::get($url);
        if(!$resp->ok()) {
            return [NULL, new \Qiniu\Http\Error($url, $resp)];
        }
        if($resp->json() !== NULL) {
            return [$resp->json(), NULL];
        }
        return [$resp->body, NULL];
    }
    public function buildUrl($key, $fops, $protocol = "http")
    {
        if(is_array($fops)) {
            $fops = implode("|", $fops);
        }
        $url = $protocol . "://" . $this->domain . "/" . $key . "?" . $fops;
        if($this->auth !== NULL) {
            $url = $this->auth->privateDownloadUrl($url, $this->token_expire);
        }
        return $url;
    }
}

?>